class sysinit::repo {
  
  if $::operatingsystemmajrelease {
    $os_maj_release = $::operatingsystemmajrelease
  } else {
    $os_versions    = split($::operatingsystemrelease, '[.]')
    $os_maj_release = $os_versions[0]
  }
  
  $_os_versions = split($::operatingsystemrelease, '[.]')
  $_os_maj_release = $_os_versions[0]
  $_os_min_release = $_os_versions[1]
  
  if $sysinit::manage_repo == true {
    $local_repo_enable = '1'
    $remote_repo_enable = '0'
  } else {
    $local_repo_enable = '0'
    $remote_repo_enable = '1'
  }
  
  #repo base_local params
  $base_baseurl = "${sysinit::yum_server_url}/rhel${_os_maj_release}${_os_min_release}"
  
#  #repo updates_local params
#  $updates_baseurl = "${sysinit::yum_server_url}/CentOS${os_maj_release}_\$basearch/updates/Packages"
  
#  #repo extras_local params
#  $extras_baseurl = "${sysinit::yum_server_url}/CentOS${os_maj_release}_\$basearch/extras/Packages"
  
#  #repo puppet_local params
#  $puppet_baseurl = "${sysinit::yum_server_url}/puppet/el${os_maj_release}_\$basearch/"

  Yumrepo {
    enabled  => $local_repo_enable,
    gpgcheck => '0',
  }
  
  yumrepo { "DPCA-redhat${_os_maj_release}${_os_min_release}":
    baseurl => $base_baseurl,
    descr   => "Red Hat Enterprise Linux ${_os_maj_release}.${_os_min_release}",
  }
  
#  yumrepo { 'updates_local':
#    baseurl => $updates_baseurl,
#    descr   => "CentOS-${os_maj_release} - Updates - Local",
#  }
#  
#  yumrepo { 'extras_local':
#    baseurl => $extras_baseurl,
#    descr   => "CentOS-${os_maj_release} - Extras - Local",
#  }
#  
#  yumrepo { 'puppet_local':
#    baseurl => $puppet_baseurl,
#    descr   => "puppet_${os_maj_release} - Local",
#  }
  
  #diabled default repo
  yumrepo { ['base', 'extras', 'updates']:
    enabled  => $remote_repo_enable,
    gpgcheck => '1',
  }
  
}